<?php
declare (strict_types=1);

namespace app\common\model;

class News extends Base
{
    protected $name = 'news';

    public function getTypeAttr($value)
    {
        switch ($value) {
            case 1:
                return '新闻';
            case 2:
                return '公告';
            default:
                return '新闻';
        }
    }

    public function getContentAttr($value)
    {
        return htmlspecialchars_decode($value);
    }


    public static function recordLog($model)
    {

        $emp_id = session('admin_id');
        $emp_name = Admin::where('id', $emp_id)->value('admin_name');
        $title = '新闻公告';
        $operation = getOperation($model->operation);
        if(in_array($model->operation,['updateAll','deleteAll'])){
            $msg = $operation .'【' . $title . '】'. '标识ID【' . implode(',',$model->ids) . '】';
            Logs::adds($msg, $emp_id, $emp_name);
        }else{
            $msg = $operation .'【' . $title . '】'. '标识ID【' . $model->id . '】标题【' . $model->title . '】';
            Logs::adds($msg, $emp_id, $emp_name);
        }
    }



}
